package com.ktgj.pay.YeeBaoPay;


import com.epos.facade.EposFacade;
import com.epos.util.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import java.util.HashMap;
import java.util.Map;

/**
 * <p> EPOS测试用消费</p>
 * @Title: EposPayUtill.java
 * @Projectname: yeepaytest
 * @Package: com.yeepay.epos
 * @Copyright: Copyright (c)2014hmacKey
 * @Company: YeePay
 * @version: 1.0
 * @Create: 2014年3月9日
 */
public class EposDemo {
	//TODO .易宝
	private static final Log log = LogFactory.getLog(EposDemo.class);

		/*
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,TODO [商品编号："10012464064"],hmacKey,hm,TODO[请求可以换成（GET）"POST"], "gbk");
		商品编号：10012464064（只有第一次需要验证码）
		商品编号：10011888556（无需要验证码）
		*/

	/**
	 * <p>信用卡消费</p>
	 * @Title eposSale
	 * @throws Exception
	 * @return void
	 * @Create 2014年4月2日
	 */
	public static void eposSale() throws Exception{
		log.info("-------------------------信用卡消费-------------------------");
		String p0_Cmd = "EposSale";//业务类型:(固定值“EposSale”)
		String p2_Order = "1650867896";//"test001";//商户订单号
		String p3_Amt="0.1";//消费金额:(最小值为 0.1 元)
		String p4_Cur="CNY";//交易币种:(固定值 “CNY”)
		String p5_Pid="flight";//商品名称:(此参数如用到中文,请注意转码)
		String p8_Url="http://www.test.com/Text.aspx";//接收支付结果地址:(用 request 接收结果,如该地址设置 为localhost 或127.0.0.1将收不到交易结果返回)
		/**
		 * 身份证：IDCARD ; 护照：PASSPORT ; 军官证：OFFICERPASS; 澳居民往来内地通行证：HM_VISITORPASS ; 台湾居民来往大陆通行证：T_VISITORPASS; 其它：OTHER
		 * */

		String pa_CredType="IDCARD";//证件类型
		String pb_CredCode="220106198109220818";//证件号码
		String pd_FrpId = "";//银行编码
		String pe_BuyerTel="18310769919";//消费者手机号
		String pf_BuyerName="李谋";//消费者姓名
		String pm_Period="3";//订单有效期
		String pn_Unit="day";//有效期单位
		String pt_ActId="4392260032108100";//信用卡卡号
		String pa0_Mode="";//控制位
		String pa1_AuthorizeAmount="0.1";//预授权金额
		String pa2_ExpireYear="2026";//有效期（年）
		String pa3_ExpireMonth="02";//有效期（月）
		String pa4_CVV="771";//CVV

//		//220106198109220818
//		String pb_CredCode="140728199808160055";//证件号码:(此参数如用到中文,请注意转码)
//		String pd_FrpId = "";//银行编码
//		//18310769919
//		String pe_BuyerTel="17635156215";//消费者手机号
//		String pf_BuyerName="刘健";//消费者姓名:(此参数如用到中文，请注意转码)
//		//4392260032108100
//		String pt_ActId="6226553322895031";//信用卡卡号:(不能小于当前日期)
//		String pa2_ExpireYear="2024";//有效期（年）:(信用卡有效期格式：MM/YY)
//		String pa3_ExpireMonth="08";//有效期（月）:(信用卡有效期格式：MM/YY)
//		String pa4_CVV="117";//CVV:(信用卡背面签名处最后三位数)
		//风控扩展参数:(JSON 格式)
//		String prisk_Param = "{\"industry\":\"4511\",\"air_IsMember\":\"1\",\"air_ApplicationMode\":\"B2C\",\"air_Phone\":\"15215317596\",\"air_ContactPhone\":\"15215317596\",\"air_ContactName\":\"张三\",\"air_Flight\":[{\"air_FlightNo\":\"MU5102\",\"air_Cabin\":\"N\",\"air_STime\":\"20140402080000\",\"air_ETime\":\"20140402101000\",\"air_SCity\":\"PEK\",\"air_ECity\":\"SHA\"}],\"air_Passenger\":[{\"air_Name\":\"李强\",\"air_CertificateType\":\"OTHER\",\"air_CertificateNo\":\"11111111\",\"air_Email\":\"\",\"air_FlightNo\":\"MU5102\",\"air_STime\":\"20140402080000\",\"air_Phone\":\"\",\"air_Pnr\":\"\",\"air_TicketNo\":\"\",\"air_Type\":\"00\"}]}";
		String pr_NeedResponse="1";//需要应答:(固定值“1”)
		String prisk_Param = "";

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//商户订单号
		hm.put("p3_Amt",p3_Amt);//消费金额
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Pid",p5_Pid);//商品名称
		hm.put("p8_Url",p8_Url);//接收支付结果地址
		hm.put("pa_CredType",pa_CredType);//证件类型
		hm.put("pb_CredCode",pb_CredCode);//证件号码
		hm.put("pd_FrpId",pd_FrpId);//银行编码
		hm.put("pe_BuyerTel",pe_BuyerTel);//消费者手机号
		hm.put("pf_BuyerName",pf_BuyerName);//消费者姓名
		hm.put("pt_ActId",pt_ActId);//信用卡卡号
		hm.put("pa2_ExpireYear",pa2_ExpireYear);//有效期（年）
		hm.put("pa3_ExpireMonth",pa3_ExpireMonth);//有效期（月）
		hm.put("pa4_CVV",pa4_CVV);//CVV
		hm.put("pe_IsBind","1");//是否绑卡
		hm.put("pe_Identitytype","3");//用户标识
		hm.put("pe_Identityid","userId456");//标识数据
		hm.put("prisk_Param", prisk_Param);//风控扩展参数
		hm.put("pr_NeedResponse",pr_NeedResponse);//需要应答
		String hmacKey = "b4rT631521oQ85Go1L92q5110XUlXYV72ZK6z4xD101VZ91C2ok38X725Q1U";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012434762",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>验证码消费接口</p>
	 * @Title eposVerifySale
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月2日
	 */
	public static void eposVerifySale() throws Exception{
		log.info("-------------------------验证码消费-------------------------");
		String p0_Cmd = "EposVerifySale";//业务类型:(固定值“EposVerifySale”)
		String p2_Order = "1652148089555";//"test001";//商品订单号
		String pb_VerifyCode="592989";//验证码

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//商户订单号
		hm.put("pb_VerifyCode",pb_VerifyCode);//验证码

		String hmacKey = "b4rT631521oQ85Go1L92q5110XUlXYV72ZK6z4xD101VZ91C2ok38X725Q1U";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012434762",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>验证码获取接口</p>
	 * @Title eposVerifySale
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月2日
	 */
	public static void EposVerifyCodeReceive() throws Exception{
		log.info("-------------------------验证码获取-------------------------");
		String p0_Cmd = "EposVerifyCodeReceive";//业务类型:(固定值“EposVerifyCodeReceive”)
		String p2_Order = "EposTest20150106999";//"test001";//商户订单号

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//商户订单号

		String hmacKey = "aac2f9ef7e18936d3f7e76e6fb874170";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>消费订单查询</p>
	 * @Title QueryOrdDetail
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月2日
	 */
	public static void QueryOrdDetail() throws Exception{
		log.info("-------------------------消费订单查询-------------------------");
		String p0_Cmd = "QueryOrdDetail";//业务类型:(固定值” QueryOrdDetail”)
		String p2_Order = "201411031843227345709771";//"test001";//商户订单号
		String p3_ServiceType = "";//"test001";//查询类型:(不填或填固定值：0)

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//商户订单号
		hm.put("p3_ServiceType",p3_ServiceType);//查询类型

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>信用卡退款</p>
	 * @Title RefundOrd
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月28日
	 */
	public static void RefundOrd() throws Exception{
		log.info("-------------------------信用卡退款-----------------------");
		String p0_Cmd = "RefundOrd";//业务类型:(固定值 “RefundOrd”)
		String p2_Order = "1652147202";//"test001";//商品订单号
		String pb_TrxId = "YP2205101318280966360";//易宝支付交易流水号:(易宝支付平台产生的交易流水号，每笔订单 唯一)
		String p3_Amt = "1";//退款金额
		String p4_Cur="CNY";//交易币种:(不填或填固定值 ”CNY”)
		String p5_Desc = "买错商品";//退款说明:(此参数如用到中文，请注意转码)

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//退款请求号(商品订单号)
		hm.put("pb_TrxId",pb_TrxId);//易宝支付交易流水号
		hm.put("p3_Amt",p3_Amt);//退款金额
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Desc",p5_Desc);//退款说明

		String hmacKey = "b4rT631521oQ85Go1L92q5110XUlXYV72ZK6z4xD101VZ91C2ok38X725Q1U";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012434762",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}


	/**
	 * <p>预授权</p>
	 * @Title EposAuth
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月28日
	 */
	public static void EposAuth() throws Exception{
		log.info("-------------------------预授权-------------------------");
		String p0_Cmd = "EposLinkSale";//业务类型
		String p2_Order = "201411031843227345709113";//"test001";//商户订单号
		String p4_Cur="CNY";//交易币种
		String p5_Pid="flight";//商品名称
		String p8_Url="http://www.test.com/Text.aspx";//接收支付结果地址
		String pa_CredType="IDCARD";//证件类型
		String pb_CredCode="220106198109220818";//证件号码
		String pd_FrpId = "";//银行编码
		String pe_BuyerTel="18310769919";//消费者手机号
		String pf_BuyerName="李谋";//消费者姓名
		String pm_Period="3";//订单有效期
		String pn_Unit="day";//有效期单位
		String pt_ActId="4392260032108100";//信用卡卡号
		String pa0_Mode="";//控制位
		String pa1_AuthorizeAmount="0.1";//预授权金额
		String pa2_ExpireYear="2028";//有效期（年）
		String pa3_ExpireMonth="07";//有效期（月）
		String pa4_CVV="117";//CVV
		String pa5_BankBranch="beijing";//分行
		String pa6_CardType="VISA";//信用卡类型
		String pr_NeedResponse="1";//需要应答

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("p2_Order",p2_Order);//商户订单号
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Pid",p5_Pid);//商品名称
		hm.put("p8_Url",p8_Url);//接收支付结果地址
		hm.put("pa_CredType",pa_CredType);//证件类型
		hm.put("pb_CredCode",pb_CredCode);//证件号码
		hm.put("pd_FrpId",pd_FrpId);//银行编码
		hm.put("pe_BuyerTel",pe_BuyerTel);//消费者手机号
		hm.put("pf_BuyerName",pf_BuyerName);//消费者姓名
		hm.put("pm_Period",pm_Period);//订单有效期
		hm.put("pn_Unit",pn_Unit);//有效期单位
		hm.put("pt_ActId",pt_ActId);//信用卡卡号
		hm.put("pa0_Mode",pa0_Mode);//控制位
		hm.put("pa1_AuthorizeAmount",pa1_AuthorizeAmount);//预授权金额
		hm.put("pa2_ExpireYear",pa2_ExpireYear);//有效期（年）
		hm.put("pa3_ExpireMonth",pa3_ExpireMonth);//有效期（月）
		hm.put("pa4_CVV",pa4_CVV);//CVV
		hm.put("pa5_BankBranch", pa5_BankBranch);//分行
		hm.put("pa6_CardType", pa6_CardType);//信用卡类型
		hm.put("pr_NeedResponse",pr_NeedResponse);//需要应答

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>预授权完成</p>
	 * @Title eposConf
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年5月7日
	 */
	public static void eposConf() throws Exception{
		log.info("-------------------------预授权完成-----------------------");
		String p0_Cmd = "EposConf";//业务类型
		String pb_TrxId = "YP2110141440080790372";//易宝支付交易流水号
		String p3_Amt="0.1";//确认金额

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);////业务类型
		hm.put("pb_TrxId",pb_TrxId);//易宝支付交易流水号
		hm.put("p3_Amt",p3_Amt);//确认金额

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>预授权撤销</p>
	 * @Title eposCancel
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年5月7日
	 */
	public static void eposCancel() throws Exception{
		log.info("-------------------------预授权撤销-----------------------");
		String p0_Cmd = "EposCancel";//业务类型
		String pb_TrxId = "YP2110141446170312877";//易宝支付交易流水号

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);//业务类型
		hm.put("pb_TrxId",pb_TrxId);//易宝支付交易流水号

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>借记卡消费</p>
	 * @Title eposCancel
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年5月7日
	 */
	public static void EposDebitSaleNew() throws Exception{
		log.info("-------------------------借记卡消费-----------------------");
		String p0_Cmd = "EposDebitSaleNew";//业务类型:(固定值“EposDebitSaleNew”)
//		String p2_Order="1525090357384052736";//商户交易号
		String p2_Order="46453161118568451";//商户交易号
		String p3_Amt = "0.10";//交易金额:(最小值为0.1元)
		String p4_Cur = "CNY";//交易币种:(固定值“CNY”)
		String p5_Pid = "JSJ_GOODS";//商品名称:(此参数如用到中文，请注意转码)
		String p8_Url = "127.0.0.1";//回调地址:(用 request 接收结果,如该地址设置 为localhost 或127.0.0.1将收不到交易结果返回)
		//http://172.16.7.51/payment2/pay/yeepayPhoneCallback.do
		String pa_CredType = "IDCARD";//证件类型:(身份证：IDCARD)
		String pb_CredCode = "231182200010260536";//证件号码:(此参数如用到中文，请注意转码)
		String pe_BuyerTel = "18745654672";//手机号
		String pf_BuyerName = "李博洋";//消费者姓名
		String pt_ActId = "6212260913001854847";//账号
		String pr_NeedResponse="1";//需要应答:(固定值“1”)
//YP2205121927402313798
		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);//业务类型
		hm.put("p2_Order",p2_Order);//商户交易号
		hm.put("p3_Amt",p3_Amt);//交易金额
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Pid",p5_Pid);//商品名称
		hm.put("p8_Url",p8_Url);//回调地址
		hm.put("pa_CredType",pa_CredType);//证件类型
		hm.put("pb_CredCode",pb_CredCode);//证件号码
		hm.put("pe_BuyerTel",pe_BuyerTel);//手机号
		hm.put("pf_BuyerName",pf_BuyerName);//消费者姓名
		hm.put("pt_ActId",pt_ActId);//账号
		hm.put("pr_NeedResponse",pr_NeedResponse);//需要应答
		EposFacade.setTimeOut(10000);

//		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
//		String hmacKey = "9324Kcqk0W4fIM9o216pK7kn4qf582c657o6mQ1db13GQwI6oIo1x202165P";//签名数据
		String hmacKey = "9324Kcqk0W4fIM9o216pK7kn4qf582c657o6mQ1db13GQwI6oIo1x202165P";
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10011888556",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>借记卡退款</p>
	 * @Title eposCancel
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年5月7日
	 */
	public static void EposDebitRefundNew() throws Exception{
		log.info("-------------------------借记卡退款-----------------------");
//		String p0_Cmd = "RefundOrd";//业务类型:(固定值“RefundOrd”)
//		String p2_Order="46453161118568451";//商户交易号
//		String pb_TrxId = "YP2205261744331006324";//易宝支付交易流水号
//		String p3_Amt = "0.10";//退款金额
//		String p4_Cur = "CNY";//交易币种:(不填或填固定值“CNY”)
//		String p5_Desc = "测试";//退款说明:(此参数如用到中文，请注意转码)
		String p0_Cmd = "RefundOrd";//业务类型:(固定值“RefundOrd”)
		String p2_Order="1529754449935859712";//商户交易号
		String pb_TrxId = "YP2205261721172503131";//易宝支付交易流水号
		String p3_Amt = "396.00";//退款金额
		String p4_Cur = "CNY";//交易币种:(不填或填固定值“CNY”)
		String p5_Desc = "测试";//退款说明:(此参数如用到中文，请注意转码)

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);//业务类型
		hm.put("p2_Order",p2_Order);//退款请求号
		hm.put("pb_TrxId",pb_TrxId);//易宝支付交易流水号
		hm.put("p3_Amt",p3_Amt);//消费金额（退款金额）
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Desc",p5_Desc);//退款说明

		//d5490ed54a4a929ed07f7ab920955f8e
		String hmacKey = "9324Kcqk0W4fIM9o216pK7kn4qf582c657o6mQ1db13GQwI6oIo1x202165P";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10011888556",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>二次支付——首次支付</p>
	 * @Title EposBindSale
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年7月6日
	 */
	public static void EposBindSale() throws Exception{
		log.info("-------------------------二次支付——首次支付-----------------------");
		String p0_Cmd = "EposDebitSaleNew";//业务类型
		String p8_isBind = "true";//是否绑定
		String p2_Order="F1407061712479713522";//商户交易号
		String p3_Amt = "0.1";//消费金额
		String p4_Cur = "CNY";//交易币种
		String p11_Url="test";
		String p9_LoginId = "lzh";
		String p6_customerName = "李博洋";//顾客姓名
		String pf_BuyerName="李博洋";//持有人名称
		String pb_CredCode = "231182200010260536";//证件号码
		String pt_ActId = "6212260913001854847";//账号
		String pa_CredType="IDCARD";//证件类型
		String p7_CredNo = "320923199110222114";
		String pa_CardType = "DEBITCARD";
		String pa4_CVV="632";//CVV
		String pa2_ExpireYear = "2026";//有效期（年）
		String pa3_ExpireMonth="04";//有效期（月）
		String pe_BuyerTel = "18745654672";//手机号
		String p10_payType = "WEB";
		String pr_NeedResponse="1";//需要应答

		Map<String,String> hm=new HashMap<String,String>();
		//EposBindSale
		hm.put("p0_Cmd",p0_Cmd);//业务类型
		hm.put("p8_isBind",p8_isBind);//是否绑定
		//F1407061712479713522
		hm.put("p2_Order",p2_Order);//商户交易号
		hm.put("p3_Amt",p3_Amt);//消费金额
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p11_Url",p11_Url);
		hm.put("p9_LoginId",p9_LoginId);
		hm.put("p6_customerName",p6_customerName);//顾客姓名
		hm.put("pf_BuyerName",pf_BuyerName);//持有人名称
		hm.put("pb_CredCode",pb_CredCode);//证件号码
		hm.put("pt_ActId",pt_ActId);//账号
		hm.put("pa_CredType",pa_CredType);//证件类型
		hm.put("p7_CredNo",p7_CredNo);
		hm.put("pa_CardType",pa_CardType);
		hm.put("pa4_CVV",pa4_CVV);//CVV
		hm.put("pa2_ExpireYear",pa2_ExpireYear);//有效期（年）
		hm.put("pa3_ExpireMonth",pa3_ExpireMonth);//有效期（月）
		hm.put("pe_BuyerTel",pe_BuyerTel);//手机号
		hm.put("p10_payType",p10_payType);
		hm.put("pr_NeedResponse",pr_NeedResponse);//需要应答

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>分账</p>
	 * @Title EposBindSale
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年7月6日
	 */
	public static void ASEposSale() throws Exception{
		log.info("-------------------------分账-----------------------");
		String p0_Cmd = "ASEposSale";//业务类型
		String p2_Order = "20140728002";//商户交易号
		String p3_Amt = "0.1";//消费金额
		String p4_Cur = "CNY";//交易币种
		String p5_Pid = "商品名称";//商品名称
		String p6_Pdetail = "";
		String p7_MP = "";
		String p8_Url = "localhost";//回调地址
		String pa_CredType = "IDCARD";//证件类型
		String pb_CredCode = "231182200010260536";//证件号码
		String pd_FrpId = "ICBKCNBJ";//银行编码
		String pe_BuyerTel = "18745654672";//手机号
		String pf_BuyerName = "李博洋";//持有人名称
		String pt_ActId = "6212260913001854847";//账号
		String pa0_Mode = "";//控制位
		String pa2_ExpireYear = "2028";//有效期（年）
		String pa3_ExpireMonth = "07";//有效期（月）
		String pa4_CVV = "893";//CVV
		String pa5_BankBranch = "beijing";//分行
		String pa6_CardType = "";//信用卡类型
		String pa_Details = "Default:cocoa317@sina.com:0.1";
		String pc_AutoSplit = "1";
		String pr_NeedResponse = "0";//需要应答

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmd);//业务类型
		hm.put("p2_Order",p2_Order);//商户交易号
		hm.put("p3_Amt",p3_Amt);//消费金额
		hm.put("p4_Cur",p4_Cur);//交易币种
		hm.put("p5_Pid",p5_Pid);//商品名称
		hm.put("p6_Pdetail",p6_Pdetail);
		hm.put("p7_MP",p7_MP);
		hm.put("p8_Url",p8_Url);//回调地址
		hm.put("pa_CredType",pa_CredType);//证件类型
		hm.put("pb_CredCode",pb_CredCode);//证件号码
		hm.put("pd_FrpId",pd_FrpId);//银行编码
		hm.put("pe_BuyerTel",pe_BuyerTel);//手机号
		hm.put("pf_BuyerName",pf_BuyerName);//持有人名称
		hm.put("pt_ActId",pt_ActId);//账号
		hm.put("pa0_Mode",pa0_Mode);//控制位
		hm.put("pa2_ExpireYear",pa2_ExpireYear);//有效期（年）
		hm.put("pa3_ExpireMonth",pa3_ExpireMonth);//有效期（月）
		hm.put("pa4_CVV",pa4_CVV);//CVV
		hm.put("pa5_BankBranch",pa5_BankBranch);//分行
		hm.put("pa6_CardType",pa6_CardType);//信用卡类型
		hm.put("pa_Details",pa_Details);
		hm.put("pc_AutoSplit",pc_AutoSplit);
		hm.put("pr_NeedResponse",pr_NeedResponse);//需要应答

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * 获取接口输入项
	 * @throws Exception
	 */
	public static void eposInputParamsReceive() throws Exception{
		log.info("-----------获取接口输入项-----------------");
		String p0_Cmdv = "EposInputParamsReceive";//业务类型
		String pt_ActId = "4062521234567891";//账号
		String pt_CusWay = "INTERFACE_CREDIT_AUTHANDCONFIRM";

		Map<String,String> hm=new HashMap<String,String>();
		hm.put("p0_Cmd",p0_Cmdv);//业务类型
		hm.put("pt_ActId",pt_ActId);//账号
		hm.put("pt_CusWay",pt_CusWay);

		String hmacKey = "yARBp2R538472l823F35T440FR00rI1uG19he1JRI7XZV63PqZK79z143po0";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10012464064",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>回调数据解析，失败</p>
	 * @Title callbackDeal
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月28日
	 */
	public static void callbackDeal() throws Exception{
		log.info("-------------------------回调处理-----------------------");
		String r0_Cmd = "EposFailed";//业务类型
		String r1_Code = "-100";
		String r2_TrxId = "315222276759332I";
		String r3_Amt = "0.1";
		String r6_Order = "404011824001";
		String rp_TrxDate = "20140402180007";
		String rp_Msg = "%D6%A7%B8%B6%D0%C5%CF%A2%B4%ED%CE%F3";

		Map<String,String>  hm = new HashMap<String, String>();
		hm.put("r0_Cmd",r0_Cmd);//业务类型
		hm.put("r1_Code",r1_Code);
		hm.put("r2_TrxId",r2_TrxId);
		hm.put("r3_Amt",r3_Amt);
		hm.put("rp_TrxDate",rp_TrxDate);
		hm.put("r6_Order",r6_Order);
		hm.put("rp_Msg",rp_Msg);

		String hmacKey = "913ef8579f672c2ad52bfbe9b407a475";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10001126856",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>返回参数校验</p>
	 * @Title callbackDeal
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月28日
	 */
	public static void responseHmacCheck() throws Exception{
		log.info("-------------------------返回参数校验-----------------------");
		String r0_Cmd = "EposDebitSaleNew";
		String r1_Code = "1";
		String errorMsg = "";
		String r2_TrxId = "868413640611927D";
		String r3_Amt = "0.1";
		String r4_Cur = "RMB";
		String r6_Order = "20140509P1537P2179";
		String ro_BankOrderId = "4033331165050002";
		String r7_BType = "1";
		String r_SystemsSign = "";
		String r_SystemsCustomerSign = "";
		String rp_PayDate = "20140509033739";
		String ru_Trxtime = "20140509033743";

		Map<String,String>  hm = new HashMap<String, String>();
		hm.put("r0_Cmd",r0_Cmd);
		hm.put("r1_Code",r1_Code);
		hm.put("errorMsg",errorMsg);
		hm.put("r2_TrxId",r2_TrxId);
		hm.put("r3_Amt",r3_Amt);
		hm.put("r4_Cur",r4_Cur);
		hm.put("r6_Order",r6_Order);
		hm.put("ro_BankOrderId",ro_BankOrderId);
		hm.put("r7_BType",r7_BType);
		hm.put("r_SystemsSign",r_SystemsSign);
		hm.put("r_SystemsCustomerSign",r_SystemsCustomerSign);
		hm.put("rp_PayDate",rp_PayDate);
		hm.put("ru_Trxtime",ru_Trxtime);

		String hmacKey = "6ac5b7513082054c2d12951ce2d1408d";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10001126856",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	/**
	 * <p>回调数据解析，成功</p>
	 * @Title callbackDeal
	 * @throws Exception
	 * @return void
	 * @author shihj
	 * @Create 2014年4月28日
	 */
	public static void callbackBuy() throws Exception{
		log.info("-------------------------回调处理-----------------------");
		String r0_Cmd = "Buy";
		String r1_Code = "1";
		String r2_TrxId = "818141048462242E";
		String r3_Amt = "0.1";
		String r4_Cur = "RMB";
		String r5_Pid = "";
		String r6_Order = "201404161000249272";
		String r7_Uid = "";
		String r8_MP= "";
		String r9_BType = "2";
		String ru_Trxtime = "20140416112637";
		String ro_BankOrderId = "019206";
		String rb_BankId = "CCBCREDIT-NET";
		String rp_PayDate = "20140416104438";
		String rq_CardNo = "";
		String rq_SourceFee = "0.0";
		String rq_TargetFee = "0.0";

		Map<String,String>  hm = new HashMap<String, String>();
		hm.put("r0_Cmd",r0_Cmd);
		hm.put("r1_Code",r1_Code);
		hm.put("r2_TrxId",r2_TrxId);
		hm.put("r3_Amt",r3_Amt);
		hm.put("r4_Cur",r4_Cur);
		hm.put("r5_Pid",r5_Pid);
		hm.put("r6_Order",r6_Order);
		hm.put("r7_Uid",r7_Uid);
		hm.put("r8_MP",r8_MP);
		hm.put("r9_BType",r9_BType);
		hm.put("ru_Trxtime",ru_Trxtime);
		hm.put("ro_BankOrderId",ro_BankOrderId);
		hm.put("rb_BankId",rb_BankId);
		hm.put("rp_PayDate",rp_PayDate);
		hm.put("rq_CardNo",rq_CardNo);
		hm.put("rq_SourceFee",rq_SourceFee);
		hm.put("rq_TargetFee",rq_TargetFee);

		String hmacKey = "e7f704be31be20fc6a6cafd2b73adabd";//签名数据
		String eposReqUrl = Configuration.getInstance().getValue("eposReqUrl");
		Map<String,String>  result = EposFacade.trxRequest(eposReqUrl,"10001126856",hmacKey,hm, "POST", "gbk");
		log.info(result);
	}

	public static void main(String[] args) throws Exception {
//		eposSale();				    // 消费（交易成功）
//		eposVerifySale();		    // 验证码消费(交易成功)
//		QueryOrdDetail();		    // 查询（查询正常）
//		RefundOrd();				// 退款(退款成功)
//		callbackDeal();				//TODO 回调处理(p0_Cmd is null)
//		responseHmacCheck();		//TODO 返回参数校验(p0_Cmd is null)
//		callbackBuy();				//TODO 回调处理(p0_Cmd is null)
//		EposAuth();					//TODO 预授权(找不到资源包)
//		eposConf();					//TODO 预授权完成(响应结果：8005)
//		eposCancel();				//TODO 预授权撤销(响应结果：8005)
		EposDebitRefundNew();		// 借记卡退款(退款成功)
//		EposBindSale();				// 二次支付——首次支付(交易成功)
//		EposDebitSaleNew();			// 借记卡消费(交易成功)
//		eposInputParamsReceive();	// 获取接口输入项(交易成功)

		/*EposVerifyCodeReceive();  //TODO 验证码获取(订单不存在)*/
		/*EposRevocation();			//TODO 撤销(订单不存在)*/
		/*ASEposSale();				//TODO 分账(errorMsg=请求参数无效、checkHmac is error)*/
	}
}
